import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);
// ===================================================== //
// 解决push和replace的bug
const originalPush = Router.prototype.push;
Router.prototype.push = function (location) {
    return originalPush.call(this, location, () => { });
}
const originalReplace = Router.prototype.replace;
Router.prototype.replace = function (location) {
    return originalReplace.call(this, location, () => { });
}
// ===================================================== //





export default new Router({
    routes: [
        {
            path: '/',
            redirect: '/dashboard'
        },
        {
            path: '/',
            component: () => import(/* webpackChunkName: "dashboard" */'../components/common/Home.vue'),
            meta: { title: '自述文件' },
            children: [
                {
                    path: '/dashboard',
                    component: () => import(/* webpackChunkName: "dashboard" */'@/components/page/Dashboard.vue'),
                    meta: { title: '系统首页' }
                },
                {
                    path: '/user',
                    name: "UserManager",
                    component: () => import(/* webpackChunkName: "user" */'@/components/page/UserManager'),
                    meta: { title: '用户列表' }
                },
                {
                    path: '/merchant',
                    name: "MerchantManager",
                    component: () => import(/* webpackChunkName: "merchant" */'@/components/page/Merchant/MerchantManager'),
                    meta: { title: '商户管理' }
                },
                {
                    path: '/merchantpm',
                    name: "MerchantPm",
                    component: () => import(/* webpackChunkName: "merchantpm" */'@/components/page/Merchant/MerchantPm'),
                    meta: { title: '商户排名' }
                },
                {
                    path: '/merchantdetail',
                    name: "MerchantDetail",
                    component: () => import(/* webpackChunkName: "merchantdetail" */'@/components/page/Merchant/MerchantDetail'),
                    meta: { title: '商户详情', oldpath: true }
                },
                {
                    path: '/rescue',
                    component: () => import(/* webpackChunkName: "rescue" */'@/components/page/Rescue'),
                    meta: { title: '救援任务' }
                },
                {
                    path: '/service',
                    name: "ServiceManager",
                    component: () => import(/* webpackChunkName: "service" */'@/components/page/CarService/ServiceManager'),
                    meta: { title: '服务管理' }
                },
                {
                    path: '/servicetype',
                    name: "ServiceType",
                    component: () => import(/* webpackChunkName: "servicetype" */'@/components/page/CarService/ServiceType'),
                    meta: { title: '服务类别' }
                },
                {
                    path: '/servicerelease',
                    name: "ServiceRelease",
                    component: () => import(/* webpackChunkName: "servicerelease" */'@/components/page/CarService/ServiceRelease'),
                    meta: { title: '服务发布', oldpath: true }
                },
                {
                    path: '/indentclear',
                    name: "IndentClear",
                    component: () => import(/* webpackChunkName: "indentclear" */'@/components/page/Indent/IndentClear'),
                    meta: { title: '洗车订单' }
                },
                {
                    path: '/indentmaintain',
                    name: "IndentMainTain",
                    component: () => import(/* webpackChunkName: "indentmaintain" */'@/components/page/Indent/IndentMainTain'),
                    meta: { title: '维修订单' }
                },
                {
                    path: '/indenthealth',
                    name: "IndentHealth",
                    component: () => import(/* webpackChunkName: "indenthealth" */'@/components/page/Indent/IndentHealth'),
                    meta: { title: '保养订单' }
                },
                {
                    path: '/indentjudge',
                    name: "IndentJudge",
                    component: () => import(/* webpackChunkName: "indentjudge" */'@/components/page/Indent/IndentJudge'),
                    meta: { title: '评价管理' }
                },

                {
                    path: '/notice',
                    name: "Notice",
                    component: () => import(/* webpackChunkName: "notice" */'@/components/page/NoticeRelease/Notice'),
                    meta: { title: '信息发布' }
                },
                {
                    path: '/noticerelease',
                    name: "Release",
                    component: () => import(/* webpackChunkName: "noticerelease" */'@/components/page/NoticeRelease/NoticeRelease.vue'),
                    meta: { title: '发布或编辑信息', oldpath: true, }
                },
                {
                    path: '/unstatus',
                    name: "UnStatus",
                    component: () => import(/* webpackChunkName: "unstatus" */'@/components/page/NoticeRelease/UnStatus'),
                    meta: { title: '待审核' }
                },
                {
                    path: '/UnStatusDetails',
                    name: "UnStatusDetails",
                    component: () => import(/* webpackChunkName: "UnStatusDetails" */'@/components/page/NoticeRelease/UnStatusDetails'),
                    meta: { title: '详情' }
                },
                {
                    path: '/onstatus',
                    name: "OnStatus",
                    component: () => import(/* webpackChunkName: "onstatus" */'@/components/page/NoticeRelease/OnStatus'),
                    meta: { title: '已审核' }
                },
                {
                    path: '/indentdetail',
                    name: "IndentDetail",
                    component: () => import(/* webpackChunkName: "indentdetail" */'@/components/page/Indent/IndentDetail'),
                    meta: { title: '订单详情', oldpath: true }
                },
                {
                    path: '/404',
                    component: () => import(/* webpackChunkName: "404" */'@/components/page/404.vue'),
                    meta: { title: '404' }
                },
                {
                    path: '/403',
                    component: () => import(/* webpackChunkName: "403" */'@/components/page/403.vue'),
                    meta: { title: '403' }
                },
                {
                    path: '/indentInfoView',
                    name: "IndentInfoView",
                    component: () => import(/* webpackChunkName: "indentInfoView" */'@/components/page/OrderNum/index.vue'),
                    meta: { title: '订单统计' }
                },
                {
                    path: '/systemMenus',
                    name: "SystemMenu",
                    component: () => import(/* webpackChunkName: "systemMenus" */'@/components/page/SystemMenus/SystemMenu'),
                    meta: { title: '系统管理' }
                },
                {
                    path: '/systemuser',
                    name: "SystemUser",
                    component: () => import(/* webpackChunkName: "systemuser" */'@/components/page/SystemMenus/SystemUser'),
                    meta: { title: '系统用户' }
                },
                {
                    path: '/systemrole',
                    name: "SystemRole",
                    component: () => import(/* webpackChunkName: "systemrole" */'@/components/page/SystemMenus/SystemRole'),
                    meta: { title: '系统角色' }
                },
                {
                    path: '/dictionary',
                    name: "DataDictionary",
                    component: () => import(/* webpackChunkName: "dictionary" */ '@/components/page/SystemMenus/DataDictionary'),
                    meta: { title: '数据字典' }
                },
            ]
        },
        {
            path: '/login',
            component: () => import(/* webpackChunkName: "login" */ '../components/page/Login.vue'),
            meta: { title: '登录' }
        },
        {
            path: '*',
            redirect: '/404'
        }
    ],
    mode: 'hash',
    base: process.env.BASE_URL,
});
